import java.time.LocalDateTime;

class Screening {
    private String screeningId;
    private Movie movie;
    private ScreeningRoom room;
    private LocalDateTime startTime;
    private LocalDateTime endTime;
    private double price;
    private boolean[][] seats;
    public Screening(String screeningId, Movie movie, ScreeningRoom room,
                     LocalDateTime startTime, double price) {
        this.screeningId = screeningId;
        this.movie = movie;
        this.room = room;
        this.startTime = startTime;
        this.endTime = startTime.plusMinutes(movie.getDuration());
        this.price = price;
        this.seats = new boolean[room.getRows()][room.getSeatsPerRow()];
    }
    public String getScreeningId() { return screeningId; }
    public Movie getMovie() { return movie; }
    public ScreeningRoom getRoom() { return room; }
    public LocalDateTime getStartTime() { return startTime; }
    public LocalDateTime getEndTime() { return endTime; }
    public double getPrice() { return price; }
    public void setPrice(double price) { this.price = price; }

    public boolean bookSeat(int row, int seat) {
        if (isValidSeat(row, seat) && !seats[row-1][seat-1]) {
            seats[row-1][seat-1] = true;
            return true;
        }
        return false;
    }
    public boolean cancelSeat(int row, int seat) {
        if (isValidSeat(row, seat) && seats[row-1][seat-1]) {
            seats[row-1][seat-1] = false;
            return true;
        }
        return false;
    }
    public int getAvailableSeats() {
        int count = 0;
        for (boolean[] row : seats) {
            for (boolean seat : row) {
                if (!seat) count++;
            }
        }
        return count;
    }
    public String getSeatMap() {
        StringBuilder map = new StringBuilder();
        return map.toString();
    }
    private boolean isValidSeat(int row, int seat) {
        return row > 0 && row <= room.getRows() &&
                seat > 0 && seat <= room.getSeatsPerRow();
    }
}